<?php

/**
 * 基类
 * User: tsang
 * Date: 2017/9/14
 * Time: 20:11
 */

namespace app\home\Controller;
use think\Controller;
use think\Db;

class Base extends Controller
{
    function __construct()
    {
        parent::__construct();
        $this->copyright();
        $this->project();
        $this->assign('controller',request()->controller());
    }

    public function copyright()
    {
        $data = db('web_set')->field('copyright')->where('id',1)->find();
        return $this->assign('copyright', $data);
    }

    public function project(){
        $data = db('project')->where('id', 'not in', 1)->select();
        return $this->assign('project', $data);
    }

    public function getColVal($col)
    {
        $data = db('web_set')->where('id', 1)->field($col)->find();
        $data = unserialize($data[$col]);
        return $this->assign('colval', $data);
    }

    public function getSibar($type)
    {
        $where['type'] = $type;
        $sibar = db('article')->where($where)->field('id,title')->select();
        return $this->assign('sibar', $sibar);
    }

    public function getSibarArticle($id)
    {

        $where['id'] = $id;
        $data = db('article')->where($where)->find();

        return $this->assign('article', $data);
    }

    public function _empty()
    {
        return '404';
    }
}